import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;


public class Question4 extends Question2{

	public Question4(OutputGraphs graphs) {
		super(graphs);
		
	}
	
	public void run() throws IOException {
		ExamplesInputReader reader = new ExamplesInputReader();
		ArrayList<Example> allExmples = reader.getExamples(EXAMPLES_FILE);
		//creating the the power set of all the examples 2^n combinations
		Collection<ArrayList<Example>> powerSet = getAllPowerSet(allExmples);
		QuestionData data[][]=new QuestionData[Constants.TOTAL_NUMBER_OF_DIGITS][Constants.PROB_RANG];
		
		noiseProb=0.05f;
		int p=0;
		while (noiseProb<=0.5){
			
			for (int i = 1; i <= 10; i++) {
				//get all the sets from the size i:
				Collection<ArrayList<Example>> subset =chooseExamplesSubsetBySize(i,powerSet);
				//running over all the sets
				data[i-1][p] =new QuestionData();
				
				for (ArrayList<Example> exampleSet : subset) {
					
					int numberThatLearned=checkNetwork(exampleSet);
					data[i-1][p].newNumber(numberThatLearned);
				}
				
				System.out.println(noiseProb+" : i :"+i+" max: "+data[i-1][p].getMax()+ " avg= "+data[i-1][p].getAvg());
			}
			//increase the probability
			noiseProb+=0.05f;
			noiseProb = (float)(((int)(noiseProb*100))/(float)100);
			p++;
		}
		grapic.questionFour(data);
		

				
		
	}
}
